package gui.obu.alerts.panels;

import gui.obu.AbstractObuPanelImpl;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

import com.swtdesigner.SWTResourceManager;

public abstract class AbstractAlertPanelImpl extends AbstractObuPanelImpl implements AbstractAlertPanel {

	protected Button exclamationPoint;
	
	public AbstractAlertPanelImpl(Display display, Shell shell) {
		super(display, shell);
	}

	public void open() {
		// comment out at compile time
//		shell = new Shell();
		// ***************************
		
		shell.setSize(400, 250);
		
		exclamationPoint = new Button(shell, SWT.NONE);
		exclamationPoint.setImage(SWTResourceManager.getImage(AbstractAlertPanelImpl.class, "/images/ExclamationPoint.gif"));
		exclamationPoint.setBounds(144, 10, 100, 100);
		exclamationPoint.addListener(SWT.Selection, new Listener() {
			@Override
			public void handleEvent(Event event) {
				shell.dispose();
			}
		});
		
	}
	
	public void addListener(int eventType, Listener listener) {
		exclamationPoint.addListener(eventType, listener);
	}

	@Override
	public void dispose() {
		exclamationPoint.dispose();
	}
}
